package org.csmzxy.class2333;

import java.util.Objects;

//定义一个shape类，表示图形
class Shape{
    private String type;//形状
    private String color;//颜色
    public Shape(String type,String color){
        this.color = color;
        this.type = type;
    }
    // 重写equals()方法

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Shape shape = (Shape) o;
        return type.equals(shape.type) && color.equals(shape.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, color);
    }

    @Override
    public String toString() {
        return "Shape{" +
                "type='" + type + '\'' +
                ", color='" + color + '\'' +
                '}';
    }
}
public class Example01 {
    public static void main(String[] args){
        Shape shape1 = new Shape("Circle","Red");
        Shape shape2 = new Shape("Circle","Red");
        System.out.println(shape1);
        System.out.println(shape2);
    }
}
